//
// RS Game Framework
// Copyright © 2009 Jedd Haberstro
// jhaberstro@gmail.com
// 
// $Id:
//

#ifndef RS_REFLECTION_REFLECTIONCENTER_HPP
#define RS_REFLECTION_REFLECTIONCENTER_HPP

#include "rs/Assert.hpp"
#include "rs/Portability.hpp"
#include <map>
#include <vector>

namespace rs
{
    namespace reflection
    {
        class Class;
        class ReflectionCenter
        {
        private:
            
            typedef std::vector< Class* > ClassContainer;
            typedef std::map< Char const*, RsSize > ClassIDContainer;        
            
        public:
            
            static ReflectionCenter& GetReflectionCenter();
            
            ~ReflectionCenter();

            void RegisterClass(Class* metaClass);
            
            Class const& GetClassRecord(Char8 const* name) const;
            
            Class const& GetClassRecord(RsSize classid) const;
            
            RsSize GetClassID(Char8 const* name) const;
            
            RsSize GetClassRecordCount() const;
            
        private:
            RsSize currentID_;
            ClassContainer classes_;
            ClassIDContainer classIDs_;
        };
        
        
        inline ReflectionCenter& ReflectionCenter::GetReflectionCenter() {
            static ReflectionCenter rc;
            return rc;
        }
        
        inline RsSize ReflectionCenter::GetClassRecordCount() const {
            return classes_.size();
        }
    }
}

#endif // RS_REFLECTION_REFLECTIONCENTER_HPP